// 类的属性
/**

class ShopProduct1
{
   public $price = 0;
   public $spName = '';
   public $factory = '';
   private $cost = 0; 

   public function getCost()
   {
      return $this->cost;
   }

   private function setCost($value = 0)
   {
       $this->cost = $value;
   }
}

$p2 = new ShopProduct1();

$p2->spName = 'PHP入门培训';
var_dump($p2->price,$p2->spName);
var_dump($p2->getCost());